module.exports = {
    publicPath: './',
    pluginOptions: {
        electronBuilder: {
            nodeIntegration: true,
            externals: ['electron'],
            customFileProtocol: "./"
        }
    },
    outputDir: 'static/js', // 输出文件目录为 './static/js'
    filenameHashing: true, // 启用文件名哈希
    publicPath: './static/', // 设置静态资源的基础 URL
    configureWebpack: {
        output: {
            filename: '[hash].worker.js' // 设置 worker 文件名为哈希值
        },
        module: {
            rules: [
                {
                    test: /\.js$/,
                    include: [
                        path.resolve(__dirname, 'node_modules/tesseract.js'),
                        path.resolve(__dirname, 'node_modules/worker-farm')
                    ],
                    use: {
                        loader: 'babel-loader',
                        options: {
                            presets: [
                                ['env', {
                                    targets: {
                                        browsers: ['last 2 versions'],
                                        node: 'current'
                                    },
                                    modules: 'commonjs',
                                    useBuiltIns: true
                                }]
                            ],
                            plugins: [
                                'transform-object-rest-spread',
                                'transform-runtime'
                            ]
                        }
                    }
                }
            ]
        }
    }
}